/**
 * 基金池 策略分组选择 fundpool
 */

 import React,{PropTypes,Component,PureComponent}  from 'react';
 import {Select ,Button ,Modal, Form, TreeSelect,Row,Col,message } from 'antd';
 import { connect } from 'react-redux';

 const TreeNode = TreeSelect.TreeNode;

/**
 * 策略分组选择输入控件
 * @param {[type]} data     [列表数据]
 * @param {[type]} groupNumberID [加入关注分组编号]
 */

 const mapStateToProps = state => ({
  groupNumberID: state.fundpool.groupNumberID,
 });

 @connect( mapStateToProps,null)
class PolicyGroup extends PureComponent{

  static propTypes = {

  }
  onSelect=(value, node, extra)=>{
    console.log("onSelect>value",value);
    const {data,groupNumberID} = this.props;
    console.log("onSelect>>>>>",this.props);
    data.map((item,i)=>{
      if(value === item.groupNumber){
        groupNumberID.push(value)
      }
    })
  }
  render(){
    const {data} = this.props;
    console.log('pollllll',data)
    const myProps={
  		style:{width:200},
  	}
      return (
        <TreeSelect
          {...myProps}
          placeholder="请选择加入分组"
          dropdownStyle={{ maxHeight: 200, overflow: 'auto' }}
          treeCheckable= {true}
          treeDefaultExpandAll={true}
          multiple
          onSelect={this.onSelect}
        >
          {
    				 data.map((item,i)=>
               <TreeNode value={item.groupNumber} key={item.groupNumber} title={item.groupName}/>
             )
    			}
    		</TreeSelect>
  	  )
  }
}

export {
  PolicyGroup
}
